package cn.itsource.ymcc.client.fallback;

import cn.itsource.ymcc.client.CourseFeignClient;
import cn.itsource.ymcc.client.CourseUserLearnFeignClient;
import cn.itsource.ymcc.domain.CourseUserLearn;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseUserLearnFeignClientFallbackFactory implements FallbackFactory<CourseUserLearnFeignClient> {
    @Override
    public CourseUserLearnFeignClient create(Throwable throwable) {
        return new CourseUserLearnFeignClient(){

            @Override
            public JSONResult saveOrUpdate(CourseUserLearn courseUserLearn) {
                throwable.printStackTrace();
                return JSONResult.error("学生和课程挂载失败");
            }

            @Override
            public JSONResult selectForUser( Long courseId) {
                throwable.printStackTrace();
                return JSONResult.error("查询Learn信息失败");
            }

        };
    }
}
